home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / LibraryOfCongress / LibraryOfCongress.app / MyMenuCell.m < prev    next >
Encoding:
Text File  |  1992-08-06  |  1.1 KB  |  59 lines

  1. #import "MyMenuCell.h"
  2.  
  3. @implementation  MyMenuCell
  4.  
  5. fixItem(p) char *p; {
  6.     int nl=1;
  7.     char *l = p;
  8.     squishblank(p);
  9.     while (*p){
  10.         if (*p==':' && nl && p[1])
  11.             p[1]='\t', nl=0;
  12.         else
  13.         if (*p=='\n') nl=1;
  14.         p++;
  15.     }
  16. }
  17.  
  18. - click:sender {
  19.     char buf[80000], *p = buf;
  20.     if (getItem(buf,n)){
  21.         if (strncmp(p,"\n(Record",8)==0) p = index(p,')')+1;
  22.         fixItem(p);
  23.         setText(p);
  24.     }
  25.     return self;
  26. }
  27.  
  28. - setStringValueNoCopy:(char *)s {
  29.     [super setStringValue:s];
  30.     [self setLeaf:YES];
  31.     [self setAction:@selector(click:)];
  32.     [self setTarget:self];
  33.     return self;
  34. }
  35.  
  36. #import <appkit/Font.h>
  37. #import <appkit/FontManager.h>
  38. static id f = (id)0;
  39.  
  40. - setContents:(int)N {
  41.     extern char *nthItem();
  42.     extern int nthItemIndex();
  43.     
  44.     if (!f) f = [Font newFont:"Courier" size:12.];
  45.     [self setFont:f];
  46.     [super setStringValueNoCopy:s=nthItem(N)];
  47.     n = nthItemIndex(N);
  48.     return self;
  49. }
  50.  
  51. - setStringValue: (char *)s {
  52.     return [self setStringValueNoCopy:s];
  53. }
  54.  
  55. - (char *)stringValue {
  56.     return s;
  57. }
  58.  
  59. @end